$(function() {
    $('#payslipView').button();
    $('#downloadPayrollRegister').button();
    $('#downloadPayrollBilling').button();
    $('#downloadPayrollAtm').button();
    $('#downloadPayrollCash').button();
    $('.editEmployeePayroll').button();

    $('.editEmployeePayroll').click(function(event) {
        var ids = $(this).attr('id').split('-');
        var employeeId = ids[0];
        var payrollPeriodId = ids[1];

        var path = '/payrollregister/findPayroll/' + employeeId + '/' + payrollPeriodId + '/';

        if (ids.length == 3) {
            var payrollId = ids[2];
            path = path + payrollId;
        }

        $('#payrollInfo').load(path, function() {
            $('#payrollInfo').dialog({
                title: 'Payroll Info',
                draggable: false,
                resizable: false,
                width: 630,
                modal: true,
                buttons: {'Save Payroll':function() { $('#payrollInfoForm').submit(); }}
            });
        });
    });

});
